/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package movie.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author admin
 */
@Entity
@Table(name = "film")
@NamedQueries({
	@NamedQuery(name = "Film.findAll", query = "SELECT f FROM Film f")})
public class Film implements Serializable {

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "idFilm", fetch = FetchType.LAZY)
	private List<RoleFilm> roleFilmList;
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Basic(optional = false)
	@Column(name = "id_film")
	private Integer idFilm;
	@Basic(optional = false)
	@NotNull
	@Size(min = 1, max = 30)
	@Column(name = "name")
	private String name;
	@Lob
	@Size(max = 65535)
	@Column(name = "description")
	private String description;
	@Lob
	@Size(max = 65535)
	@Column(name = "quotes")
	private String quotes;
	@Basic(optional = false)
	@NotNull
	@Size(min = 1, max = 10)
	@Column(name = "duration")
	private String duration;
	@Basic(optional = false)
	@NotNull
	@Size(min = 1, max = 45)
	@Column(name = "imdb_link")
	private String imdbLink;
	@Size(max = 45)
	@Column(name = "amazon_link")
	private String amazonLink;
	@Size(max = 45)
	@Column(name = "trailer_link")
	private String trailerLink;
	@Size(max = 45)
	@Column(name = "image_link")
	private String imageLink;
	@Basic(optional = false)
	@NotNull
	@Column(name = "date_created")
	@Temporal(TemporalType.TIMESTAMP)
	private Date dateCreated;
	@Basic(optional = false)
	@NotNull
	@Column(name = "date_started")
	@Temporal(TemporalType.TIMESTAMP)
	private Date dateStarted;
	@Column(name = "date_deleted")
	@Temporal(TemporalType.TIMESTAMP)
	private Date dateDeleted;
	@JoinTable(name = "watched_film_detail", joinColumns = {
		@JoinColumn(name = "id_film", referencedColumnName = "id_film")}, inverseJoinColumns = {
		@JoinColumn(name = "id_user_access", referencedColumnName = "id_user_access")})
	@ManyToMany(fetch = FetchType.LAZY)
	private List<UserAccess> userWatchedList;
	@JoinTable(name = "wish_list", joinColumns = {
		@JoinColumn(name = "id_film", referencedColumnName = "id_film")}, inverseJoinColumns = {
		@JoinColumn(name = "id_user_access", referencedColumnName = "id_user_access")})
	@ManyToMany(fetch = FetchType.LAZY)
	private List<UserAccess> userWishList;
	@JoinTable(name = "film_genre", joinColumns = {
		@JoinColumn(name = "id_film", referencedColumnName = "id_film")}, inverseJoinColumns = {
		@JoinColumn(name = "id_genre", referencedColumnName = "id_genre")})
	@ManyToMany(fetch = FetchType.LAZY)
	private List<Genre> genreList;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "filmId", fetch = FetchType.LAZY)
	private List<BoxOffice> boxOfficeList;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "idFilm", fetch = FetchType.LAZY)
	private List<RoleFilm> roleList;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "idFilm", fetch = FetchType.LAZY)
	private List<Rating> ratingList;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "idFilm", fetch = FetchType.LAZY)
	private List<Comment> commentList;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "idFilm", fetch = FetchType.LAZY)
	private List<Favourite> favouriteList;

	public Film() {
	}

	public Film(Integer idFilm) {
		this.idFilm = idFilm;
	}

	public Film(Integer idFilm, String name, String duration, String imdbLink, Date dateCreated, Date dateStarted) {
		this.idFilm = idFilm;
		this.name = name;
		this.duration = duration;
		this.imdbLink = imdbLink;
		this.dateCreated = dateCreated;
		this.dateStarted = dateStarted;
	}

	public Integer getIdFilm() {
		return idFilm;
	}

	public void setIdFilm(Integer idFilm) {
		this.idFilm = idFilm;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getQuotes() {
		return quotes;
	}

	public void setQuotes(String quotes) {
		this.quotes = quotes;
	}

	public String getDuration() {
		return duration;
	}

	public void setDuration(String duration) {
		this.duration = duration;
	}

	public String getImdbLink() {
		return imdbLink;
	}

	public void setImdbLink(String imdbLink) {
		this.imdbLink = imdbLink;
	}

	public String getAmazonLink() {
		return amazonLink;
	}

	public void setAmazonLink(String amazonLink) {
		this.amazonLink = amazonLink;
	}

	public String getTrailerLink() {
		return trailerLink;
	}

	public void setTrailerLink(String trailerLink) {
		this.trailerLink = trailerLink;
	}

	public String getImageLink() {
		return imageLink;
	}

	public void setImageLink(String imageLink) {
		this.imageLink = imageLink;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public Date getDateStarted() {
		return dateStarted;
	}

	public void setDateStarted(Date dateStarted) {
		this.dateStarted = dateStarted;
	}

	public Date getDateDeleted() {
		return dateDeleted;
	}

	public void setDateDeleted(Date dateDeleted) {
		this.dateDeleted = dateDeleted;
	}

	public List<UserAccess> getUserWatchedList() {
		return userWatchedList;
	}

	public void setUserWatchedList(List<UserAccess> userWatchedList) {
		this.userWatchedList = userWatchedList;
	}

	public List<UserAccess> getUserWishList() {
		return userWishList;
	}

	public void setUserWishList(List<UserAccess> userWishList) {
		this.userWishList = userWishList;
	}

	public List<Genre> getGenreList() {
		return genreList;
	}

	public void setGenreList(List<Genre> genreList) {
		this.genreList = genreList;
	}

	public List<BoxOffice> getBoxOfficeList() {
		return boxOfficeList;
	}

	public void setBoxOfficeList(List<BoxOffice> boxOfficeList) {
		this.boxOfficeList = boxOfficeList;
	}

	public List<RoleFilm> getRoleList() {
		return roleList;
	}

	public void setRoleList(List<RoleFilm> roleList) {
		this.roleList = roleList;
	}

	public List<Rating> getRatingList() {
		return ratingList;
	}

	public void setRatingList(List<Rating> ratingList) {
		this.ratingList = ratingList;
	}

	public List<Comment> getCommentList() {
		return commentList;
	}

	public void setCommentList(List<Comment> commentList) {
		this.commentList = commentList;
	}

	public List<Favourite> getFavouriteList() {
		return favouriteList;
	}

	public void setFavouriteList(List<Favourite> favouriteList) {
		this.favouriteList = favouriteList;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (idFilm != null ? idFilm.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof Film)) {
			return false;
		}
		Film other = (Film) object;
		if ((this.idFilm == null && other.idFilm != null) || (this.idFilm != null && !this.idFilm.equals(other.idFilm))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "movie.entity.Film[ idFilm=" + idFilm + " ]";
	}

	public List<RoleFilm> getRoleFilmList() {
		return roleFilmList;
	}

	public void setRoleFilmList(List<RoleFilm> roleFilmList) {
		this.roleFilmList = roleFilmList;
	}
}
